#!/bin/sh

if [ ! -d "/sys/class/gpio/gpio46" ]; then
    echo 46 > /sys/class/gpio/export
    echo "out" > /sys/class/gpio/gpio46/direction
fi

stty -F /dev/ttyCH9344USB7 raw speed 115200 -echo min 1 time 0

if [ "$1" = "0" ]; then
    echo 0 > /sys/class/gpio/gpio46/value
    echo "485-1 Receive Begin execution"
elif [ "$1" = "1" ]; then
    echo 1 > /sys/class/gpio/gpio46/value
    echo "485-1 send Begin execution"
else
    echo "Invalid argument. Please provide either 0 or 1."
fi

